package com.example.pkmedical.Activity.help;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.pkmedical.Base.BaseActivity;
import com.example.pkmedical.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class HelpLastActivity extends BaseActivity {
    @BindView(R.id.main_house)
    ImageView mainHouse;
    @BindView(R.id.main_house_text)
    TextView mainHouseText;
    @BindView(R.id.main_date)
    TextView mainDate;
    @BindView(R.id.help_last_img)
    ImageView helpLastImg;
    @BindView(R.id.help_last_finishbt)
    Button helpLastFinishbt;
    @BindView(R.id.help_last_nextbt)
    Button helpLastNextbt;
    @BindView(R.id.help_last_lastbt)
    Button helpLastLastbt;
    private int type = -1;
    private int num = 0;
    private int now = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_help_last);
        ButterKnife.bind(this);
    }

    /**
     * 0:锁屏，1：侧翻，2：敲击，3：历史
     */
    @Override
    public void initData() {
        switch (type) {
            case 0:
                num = 1;
                helpLastImg.setImageResource(R.drawable.img_sd_new);
                helpLastNextbt.setBackgroundResource(R.drawable.help_item_white);
                helpLastNextbt.setTextColor(getResources().getColor(R.color.color_help_text));
                break;
            case 1:
                num = 3;
                helpLastImg.setImageResource(R.drawable.cf_a);
                break;
            case 2:
                num = 3;
                helpLastImg.setImageResource(R.drawable.qj_a);
                break;
            case 3:
                num = 4;
                helpLastImg.setImageResource(R.drawable.ls_a);
                break;
            case 4:
                num = 3;
                helpLastImg.setImageResource(R.drawable.img_help_zero_one);
                break;
            case 5:
                num = 2;
                helpLastImg.setImageResource(R.drawable.img_position_one);
                break;
        }
    }

    @Override
    public void initView() {
        mainHouse.setImageResource(R.drawable.img_top_help);
        mainHouseText.setText("帮助");
        Intent intent = getIntent();
        if (null != intent) {
            type = intent.getIntExtra("type", -1);

        }
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void showDialog(String... msg) {

    }

    @OnClick({R.id.help_last_finishbt, R.id.help_last_nextbt, R.id.help_last_lastbt})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.help_last_finishbt:
                finish();
//                overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                break;
            case R.id.help_last_nextbt:
                switch (type) {
                    case 0:
//                        spPlus();
                        break;
                    case 1:
                        cfPlus();
                        break;
                    case 2:
                        qjPlus();
                        break;
                    case 3:
                        lsPlus();
                        break;
                    case 4:
                        zeroPlus();
                        break;
                    case 5:
                        posPlus();
                        break;
                }

                break;
            case R.id.help_last_lastbt:
                switch (type) {
                    case 0:
//                        spReduce();
                        break;
                    case 1:
                        cfReduce();
                        break;
                    case 2:
                        qjReduce();
                        break;
                    case 3:
                        lsReduce();
                        break;
                    case 4:
                        zeroReduce();
                        break;
                    case 5:
                        posReduce();
                        break;
                }
                break;
        }
    }


    private void lsReduce() {
        if (now == 2) {
            now--;
            helpLastImg.setImageResource(R.drawable.ls_a);
            bottom();
        } else if (now == 3) {
            now--;
            helpLastImg.setImageResource(R.drawable.ls_b);
            all();
        } else if (now == 4) {
            now--;
            helpLastImg.setImageResource(R.drawable.ls_c);
            all();
        }
    }

    private void lsPlus() {
        if (now == 1) {
            now++;
            helpLastImg.setImageResource(R.drawable.ls_b);
            all();
        } else if (now == 2) {
            now++;
            helpLastImg.setImageResource(R.drawable.ls_c);
            all();
        } else if (now == 3) {
            now++;
            helpLastImg.setImageResource(R.drawable.ls_d);
            top();
        }
    }

    private void qjPlus() {
        if (now == 1) {
            now++;
            helpLastImg.setImageResource(R.drawable.qj_b);
            all();
        } else if (now == 2) {
            now++;
            helpLastImg.setImageResource(R.drawable.qj_c);
            top();
        } else if (now == 3) {

        }
    }

    private void qjReduce() {
        if (now == 1) {

        } else if (now == 2) {
            now--;
            helpLastImg.setImageResource(R.drawable.qj_a);
            bottom();
        } else if (now == 3) {
            now--;
            helpLastImg.setImageResource(R.drawable.qj_b);
            all();
        }
    }

    private void cfPlus() {
        if (now == 1) {
            now++;
            helpLastImg.setImageResource(R.drawable.cf_b);
            all();
        } else if (now == 2) {
            now++;
            helpLastImg.setImageResource(R.drawable.cf_c);
            top();
        } else if (now == 3) {

        }
    }

    private void cfReduce() {
        if (now == 1) {

        } else if (now == 2) {
            now--;
            helpLastImg.setImageResource(R.drawable.cf_a);
            bottom();
        } else if (now == 3) {
            now--;
            helpLastImg.setImageResource(R.drawable.cf_b);
            all();
        }
    }
    private void posPlus() {
        if (now < num) {
            now++;
            helpLastImg.setImageResource(R.drawable.img_position_two);
            if (now == num) {
                top();
            }
        }
    }

    private void posReduce() {
        if (now == num) {
            now--;
            helpLastImg.setImageResource(R.drawable.img_position_one);
            if (now < num) {
                bottom();
            }
        }
    }
    private void zeroPlus() {
        if (now == 1) {
            now++;
            helpLastImg.setImageResource(R.drawable.img_help_zero_two);
            all();
        } else if (now == 2) {
            now++;
            helpLastImg.setImageResource(R.drawable.img_help_zero_three);
            top();
        } else if (now == 3) {

        }
    }

    private void zeroReduce() {
        if (now == 1) {

        } else if (now == 2) {
            now--;
            helpLastImg.setImageResource(R.drawable.img_help_zero_one);
            bottom();
        } else if (now == 3) {
            now--;
            helpLastImg.setImageResource(R.drawable.img_help_zero_two);
            all();
        }
    }

//    private void spPlus() {
//        if (now < num) {
//            now++;
//            helpLastImg.setImageResource(R.drawable.sp_b);
//            if (now == num) {
//                top();
//            }
//        }
//    }
//
//    private void spReduce() {
//        if (now == num) {
//            now--;
//            helpLastImg.setImageResource(R.drawable.sp_a);
//            if (now < num) {
//                bottom();
//            }
//        }
//    }

    private void top() {

        helpLastNextbt.setBackgroundResource(R.drawable.help_item_white);
        helpLastNextbt.setTextColor(getResources().getColor(R.color.color_help_text));
        helpLastLastbt.setTextColor(getResources().getColor(R.color.green_back_text));
        helpLastLastbt.setBackgroundResource(R.drawable.help_item_back_on);
    }

    private void bottom() {

        helpLastNextbt.setBackgroundResource(R.drawable.help_item_back_on);
        helpLastNextbt.setTextColor(getResources().getColor(R.color.green_back_text));
        helpLastLastbt.setBackgroundResource(R.drawable.help_item_white);
        helpLastLastbt.setTextColor(getResources().getColor(R.color.color_help_text));
    }

    private void all() {

        helpLastNextbt.setBackgroundResource(R.drawable.help_item_back_on);
        helpLastNextbt.setTextColor(getResources().getColor(R.color.green_back_text));
        helpLastLastbt.setBackgroundResource(R.drawable.help_item_back_on);
        helpLastLastbt.setTextColor(getResources().getColor(R.color.green_back_text));
    }
}
